"""Removed cities

Revision ID: b6533af850d8
Revises: 5f0e0e8ea5ac
Create Date: 2023-01-31 15:42:49.229620

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = 'b6533af850d8'
down_revision = '5f0e0e8ea5ac'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('server_ibfk_1', 'server', type_='foreignkey')
    op.drop_constraint('order_ibfk_2', 'order', type_='foreignkey')
    op.drop_table('city')
    op.drop_column('order', 'city_id')
    op.drop_column('server', 'city_id')
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('server', sa.Column('city_id', mysql.INTEGER(), autoincrement=False, nullable=False))
    op.create_foreign_key('server_ibfk_1', 'server', 'city', ['city_id'], ['id'])
    op.add_column('order', sa.Column('city_id', mysql.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('order_ibfk_2', 'order', 'city', ['city_id'], ['id'])
    op.create_table('city',
    sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('name', mysql.VARCHAR(length=50), nullable=False),
    sa.Column('name_eng', mysql.VARCHAR(length=50), nullable=False),
    sa.Column('country_id', mysql.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('created_at', mysql.DATETIME(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
    sa.ForeignKeyConstraint(['country_id'], ['country.id'], name='city_ibfk_1'),
    sa.PrimaryKeyConstraint('id'),
    mysql_collate='utf8mb4_0900_ai_ci',
    mysql_default_charset='utf8mb4',
    mysql_engine='InnoDB'
    )
    # ### end Alembic commands ###
